using System;

namespace OhioState.AssetManaged
{
    /// <summary>
    /// A container for a floating point value that supports the
    /// <typeparamref name="IAssetManaged"/> interface and can
    /// be shared with a a publisher/subscriber pattern.
    /// </summary>
    /// <seealso cref="SharedAsset"/>
    [Serializable()]
    public class SharedFloat : SharedAsset
    {
        #region Constructors
        /// <summary>
        /// Constructor taking in an initial value.
        /// </summary>
        /// <param name="value">The initial value.</param>
        /// <remarks>The initial name will be the empty string.</remarks>
        public SharedFloat(float value) : this("",value)
        {
        }
        /// <summary>
        /// Constructor taking the name associated with this Asset
        /// </summary>
        /// <param name="name">The name to be used to access this asset.</param>
        /// <remarks>This initial value will be zero.</remarks>
        /// <seealso cref="AssetManager"/>
        public SharedFloat(String name)
            : this(name, 0.0f)
        {
        }
        /// <summary>
        /// Constructor taking in the name associated with the asset and an inital value.
        /// </summary>
        /// <param name="name">The name to be used to access this asset.</param>
        /// <param name="value">The initial value.</param>
        public SharedFloat(String name, float value)
            : base(name)
        {
            float_value = value;
        }
        #endregion

        /// <summary>
        /// Get or set the value associated with this asset.
        /// </summary>
        public float Float_Value
        {
            get { return float_value; }
            set
            {
                float_value = value;
                FireUpdateChangedEvent(this);
            }
        }

        private float float_value;
    }
}
